import javax.swing.*;
import java.util.*;
import java.io.*;

public class StaticObject implements Entity, Serializable {
	
	
	protected String DisplayName;
	protected String Name;
	protected String Description;
	protected String Orientation;
	protected ArrayList<Entity> Inventory = new ArrayList<Entity>();
	protected boolean CanBePickedUp = false;
	protected String Why = "It won't fit into your backpack!\n\n";
	protected boolean isVisible;
	protected int value;
	protected boolean isLocked;
	protected Entity key;
	protected boolean ContentsVisible;
	protected boolean isBed;
	protected int Gold;
	protected boolean forSale = false;
	
	
	public StaticObject(String a, String b, String c, String d, Entity ... entities ) {
		Orientation = a;
		DisplayName = b;
		Name = c;
		Description = d;
		setContentsVisible(true);
		isVisible = true;
		isLocked = false;
		isBed = false;
		Gold = 0;
		for (Entity i : entities) {
			Inventory.add(i);
		}
	}

	public void setGold(int a) {
		Gold = a;
	}
	
	public void forSale(boolean a) {
		forSale = a;
	}
	
	public boolean isForSale() {
		return forSale;
	}
		
	public void Display(JTextArea y) {
		y.append(Orientation + " is " + DisplayName + ". ");
		if (ContentsVisible == true) {
		if (Inventory.size() > 0) {
			y.append(Inventory.get(0).getOrientation() + " the " + Name + " is " + Inventory.get(0).getDisplayName());
			for (int i = 1; i < Inventory.size(); i++) {
				if (Inventory.get(i).getOrientation().equalsIgnoreCase(Inventory.get(i-1).getOrientation())) {
					y.append(", and " + Inventory.get(i).getDisplayName());
				} else {
					y.append(". " + Inventory.get(i).getOrientation() + " the " + Name + " is " + Inventory.get(i).getDisplayName());
				}
			}
			y.append(".");
		} else {
		}
		} else {
		}
		y.append("\n");
	}
	
	public void addEntity(Entity a) {
		Inventory.add(a);
	}
	
	public void addEntities(Entity ... entities) {
		for (Entity a : entities) {
			Inventory.add(a);
		}
	}
	
	public ArrayList<Entity> getInventory() {
		return Inventory;
	}
	
	public void removeObject(Entity a) {
		Inventory.remove(a);
	}
	
	public void Describe(JTextArea y) {
		y.append(Description + "." + "\n");	
	}
	
	public String getOrientation() {
		return Orientation;
	}
	
	public void setOrientation(String a) {
		Orientation = a;
	}
	
	public String getDisplayName(){
		return DisplayName;
	}
	
	public String getName() {
		return Name;
	}
	
	public String getDescription() {
		return Description;
	}
	
	public void Use(Player a, String b, JTextArea y, JTextField x) {		
	}
	
	public boolean TestCanBePickedUp() {
		return CanBePickedUp;
	}
	
	public void CantBePickedUp(String b) {
		CanBePickedUp = false;
		Why = b;		
	}
	
	public String CanBePickedUp_Why() {
		return Why;
	}
	
	public void printInventory(JTextArea y) {
		y.append("Searching the " + DisplayName + " you find the following items:\n\n");
		for (Entity a : Inventory) {
			y.append(a.getName());
		}
	}
	
	public void setContentsVisible(boolean a) {
		for (Entity b : Inventory) {
			b.setVisible(a);
		}
		ContentsVisible = a;
	}
	
	public void setVisible(boolean a) {
		isVisible = a;
	}
	
	public boolean isVisible() {
		return isVisible;
	}
	
	public int getValue() {
		return value;
	}
	
	public void setValue(int a) {
		value = a;
	}
	
	public void NeedsKey(Entity a) {
		key = a;
	}
	
	public void StartsLocked(boolean a) {
		isLocked = a;
	}
	
	public Entity getKey() {
		return key;
	}
	
	public void unlock() {
		isLocked = false;
	}
	
	public void lock() {
		isLocked = true;
		setContentsVisible(false);
	}
	
	public boolean isLocked() {
		return isLocked;
	}
	
	public boolean isBed() {
		return isBed;
	}
	
	public void isBed(boolean a) {
		isBed = a;
	}
	
	public double getWeight() {
		return 100.0;
	}
	
	public void modifyGold(int a) {
		Gold = Gold + a;
	}
	
	public int getGold() {
		return Gold;
	}
	

}
